package com.py.androidUtils.UI.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.py.androidUtils.UI.model.CanSeeView;
import com.py.androidUtils.base.BaseCommAdapter;
import com.readyidu.app.R;

public class WeCanSeeAdapter extends BaseCommAdapter<CanSeeView> {
	private LayoutInflater inflater;

	public WeCanSeeAdapter(Context context) {
		inflater = LayoutInflater.from(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.common_can_see_item, null);
			holder.title = (TextView) convertView.findViewById(R.id.title);
			holder.content = (TextView) convertView.findViewById(R.id.content);
			holder.select = (ImageView) convertView.findViewById(R.id.select);
			holder.line_top = (LinearLayout) convertView.findViewById(R.id.line_top);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		CanSeeView canSeeView = (CanSeeView) listData.get(position);
		holder.title.setText(canSeeView.getTitle());
		holder.content.setText(canSeeView.getContent());
		if (position == 0) {
			holder.line_top.setVisibility(View.VISIBLE);
		} else {
			holder.line_top.setVisibility(View.GONE);
		}
		if (canSeeView.isSelect()) {
			holder.select.setImageResource(R.drawable.select);
		} else {
			holder.select.setImageResource(R.drawable.select_nomal);
		}
		return convertView;
	}

	private final class ViewHolder {
		private TextView title;
		private TextView content;
		private ImageView select;
		private LinearLayout line_top;
	}
}
